package com.java.time;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeFormatterAPI {
    public static void main(String[] args) {
        // ofPattern：指定格式创建对象
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        
        // format：ZonedDateTime转为String，且指定格式
        System.out.println(dateTimeFormatter.format(ZonedDateTime.now())); // 2024-02-29 11:42:43
    }
}
